<template>
  <div
    class="bazijp-pay"
    v-if="makeSurePay"
    v-loading="loading"
    element-loading-text="确认中"
  >
    <div class="bazijp-pay__header" style="padding: 4rem 20px 0">
      <!-- <h2 style="margin-bottom: 4rem">确认是否支付</h2> -->
      <div class="title-section">
        <h1 class="main-title">·请确认是否支付·</h1>
      </div>
      <div
        class="pay-channels"
        @click="goToMakeSurePay"
        style="margin-bottom: 20px"
      >
        <a class="weixin"> 确认支付 </a>
      </div>
      <div
        class="pay-channels"
        @click="onSubmitAdd()"
        style="margin-bottom: 20px"
      >
        <a class="alipay"> 遇到情况，可重新支付 </a>
      </div>
      <div
        class="pay-channels"
        @click="onAddSubmit()"
        style="margin-bottom: 20px"
      >
        <a class="alipay"> 添加客服询问支付结果 </a>
      </div>
      <!-- <div
        style="
          height: 60px;
          line-height: 60px;
          border-bottom: 1px solid #ccc;
          border-top: 1px solid #ccc;
          color: #ffebac;
        "
        @click="goToMakeSurePay"
      >
        是否确认支付
      </div>
      <div
        style="
          height: 60px;
          line-height: 60px;
          border-bottom: 1px solid #ccc;
          color: #dddad0;
        "
        @click="onSubmitAdd()"
      >
        遇到情况，可重新支付
      </div> -->
    </div>
  </div>
</template>

<script setup>
import { ref, reactive } from "vue";
import router from "@/router";
import axios from "axios";

const makeSurePay = ref(true);
const loading = ref(false);

const goToMakeSurePay = () => {
  const data = localStorage.getItem("orderId");
  axios
    .get("/api/order/isPay?orderNum=" + data)
    .then((res) => {
      if (res.data.data) {
        router.push("/afterPay");
      } else {
        loading.value = true;
        // setTimeout(() => {
        axios
          .get("/api/order/isPay?orderNum=" + data)
          .then((res) => {
            loading.value = false;
            if (res.data.data) {
              router.push("/afterPay");
            } else {
              alert("您还未支付成功，请重新支付");
              router.push("/orderPay");
            }
          })
          .catch((error) => {
            console.error("", error);
          });
        // }, 2000);
      }
    })
    .catch((error) => {
      console.error("", error);
    });
};
const onSubmitAdd = () => {
  router.push("/orderPay");
  //   window.location.href = "https://tz.dakw.xyz/ss/11.html?tkey=3f0e6fae34";
};
const onAddSubmit = () => {
  // router.push("/orderPay");
  window.location.href = "https://tz.dakw.xyz/ss/11.html?tkey=3f0e6fae34";
};
</script>

<style scoped>
@import url("../../assets/index_static/app.css");
</style>
